import java.io.File
/*类默认是封闭的，要让某各类开放继承，必须 使用 open 关键字进行修饰。
*
*
* */
open class Product(val name: String) {
    fun description() = "Product: $name"

    open fun load() = "Nothing.."
}

class LuxuryProduct : Product("Luxury") {

    override fun load() = "LuxuryProduct loading..."

    fun special() = "LuxuryProduct special function"
}

fun main() {
    val p: Product = LuxuryProduct()
    println(p.load())

    println(p is Product)
    println(p is LuxuryProduct)
    println(p is File)

    /*if(p is LuxuryProduct){
        println((p as LuxuryProduct).special())
    }*/

    //as 类型转换
    println((p as LuxuryProduct).special())
    println(p.special())


    println(p is Any)
    println(p.toString())
}